import java.util.ArrayList;
public class Solution {
    //跳台阶
    public int jumpFloor(int target) {
        if(target<=1){
            return 1;
        }
        return jumpFloor(target-1)+jumpFloor(target-2);
    }
    //滑动窗口
    public ArrayList<ArrayList<Integer>> FindContinuousSequence(int sum) {
        ArrayList<ArrayList<Integer>> arr = new ArrayList<>();
        if (sum <= 1) {
            return arr;
        }
        int left = 1;
        int right = 1;
        int sum1 = 0;
        while (right <= (sum + 1) / 2) {
            sum1 = (left + right) * (right - left + 1) / 2;
            if (sum1 == sum) {
                int j = left;
                ArrayList<Integer> ret = new ArrayList<>();
                while (j <= right) {
                    ret.add(j);
                    j++;
                }
                arr.add(ret);
                left++;
            } else if (sum1 > sum) {
                left++;
            } else {
                right++;
            }
        }
        return arr;
    }
    //JZ74 和为S的连续正数序列
    public ArrayList<ArrayList<Integer>> FindContinuousSequence1(int sum) {
        ArrayList<ArrayList<Integer>> arr = new ArrayList<>();
        int left = 1, right = 1;
        int sum1=sum;
        while (right <=sum-1) {
            sum1 = sum1 - right;
            if (sum1 == 0) {
                int j = left;
                ArrayList<Integer> ret = new ArrayList<>();
                while (j <= right) {
                    ret.add(j);
                    j++;
                }
                arr.add(ret);
            } else if(sum1<0) {
                sum1=sum;
                left++;
                right = left;
            }else{
                right++;
            }
        }
        return arr;
    }
}